package com.cheng.sbjm.controller;


import com.cheng.sbjm.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
public class WebSocketController {

    @Autowired
    private SimpMessagingTemplate template;

    @RequestMapping("main")
    public String mainJsp(){
        return "main";
    }

    //一对一推送消息
    @Scheduled(fixedRate = 1)
    @RequestMapping("ssssss")
    public String sendQueueMessage(@RequestParam("aaa") int aaa) {
        System.out.println("后台一对一推送！"+aaa);
        User user = new User();
        user.setUserId(1);
        user.setUserName("oyzc");
        user.setAge(10);
        //this.template.convertAndSendToUser("f520185a87144e16" , "/queue/getResponse", user);
        return "sss";
    }
}
